<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
      /*   var v = "hello";
        (function () {
            alert(v);//undefined 声明未赋值
            var v = "world"
        })();
        alert(v);//hello

        (function() {
            alert(a + b + c);
            var a = "1";
            var f =function(){}
            var b = "2";
            var c = "3";
            //alert(a + b + c);
        })() */

        /* (function () {
            f2();//(1)
            
            var f1 = function () {
                console.log(1);
                alert("halo")
            };
            f1();
            function f2 () {
                console.log(2);
            };
            console.log(f1);
            //f1()
        })(); */

            /* var a = 1;
        function check() {
             a = 100;
            console.log(a);
        }
        check();
        console.log(a); */

        /* var v = "hello";
        if (true) {
            console.log(v);
            var v = "world";
        }
        console.log(v); */

        /* function rain () {
            var x = 1;

            function man () {
                 x = 10;
            }
            man();
            alert(x);
        }
        rain() */

        function rain () {
            //var x = 100;声明过下面全局没办法看见调用
            x = 100;
        }
        rain();
        console.log(x);//x未声明所以他是全局变量

        var t = "a";

        function test2() {
            console.log(t);
            t = "b";
            console.log(t);
        } 
        console.log(t);
        test2();
        console.log(t);

        var a = 1;
        function test() {
            console.log(a);
            var a = 4;
            console.log(a);
             a = 2;
            console.log(a);
        }
        test();
        console.log(a);
    </script>
</body>
</html>